package userserv

import (
	"log"
	"message"
	"net/http"
	"time"
)

func TestPushToUser(w http.ResponseWriter, r *http.Request) {
	msg := message.Message{}
	msg.MsgId, _ = message.GenerateMessageID()
	msg.MsgUser = "1000238" //receiver's account
	msg.MsgType = "1"       //1-normal msg, 2-confirm msg
	//msg.MsgContent = "321"
	msg.MsgCreateTime = time.Now().Unix()
	msg.MsgImg = "http://www.baidu.com"  //img of this msg
	msg.MsgTitle = "this is iphone push" // will be shown on the phone,should as same as everyone

	msg2 := message.Message{}
	msg2.MsgId, _ = message.GenerateMessageID()
	msg2.MsgUser = "1000245"
	msg2.MsgType = "1"
	//msg2.MsgContent = "321"
	msg2.MsgCreateTime = time.Now().Unix()
	msg2.MsgImg = "http://www.baidu.com"
	msg2.MsgTitle = "this is iphone push!"

	msgs := []message.Message{}
	msgs = append(msgs, msg)
	msgs = append(msgs, msg2)
	log.Println("msgs", msgs)

	message.SendMessage(msgs, "devMessage" /* home message or dev message */)
	//m := []byte("123")
	//a := "alert"
	//
	//push.Send(username, m)
}

func init() {
	myMux.muxHandlers.HandleFunc("/TestPushToUser", TestPushToUser)
}
